﻿/*
	Copyright 2008 CATsoft Development GmbH

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/
/*
	Create new MP3tunes account
*/

function newaccount_onOpen(){

}

function newAccount(){
	if(chbAgreement.value == true){
		if( checkEmail(edEmail.value) ){
			if(edPassword.value != "" && edPassword.value == edConfirmPw.value){
				anim = new animate();
				anim.startLodingAnimation();
				mp3t = new mp3tunes();
				mp3t.mp3_createAccount(edEmail.value, edPassword.value, edFirstname.value, edLastname.value);
			} else {
				alert(PW_DIFFERENT);
			}
		} else {
			alert(NO_VALID_EMAIL);
		}
	} else {
		alert(AGREE_TO_TERMS);
	}
}

function closeView( )
{
	var closeDetailsView = detailsViewData.getValue("closeDetailsView");
  closeDetailsView();  
}

function checkEmail(email){
	var a = false;
 var res = false;
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

	if(a == true){
		reg = new RegExp("^([a-zA-Z0-9\-\.\_]+)" + "(\@)([a-zA-Z0-9\-\.]+)" + "(\.)([a-zA-Z]{2,4})$");
		res = (reg.test(email));
	} else {
		res = (email.search("@") >= 1 && s.lastIndexOf(".") > s.search("@") && s.lastIndexOf(".") >= s.length - 5);
	}
	return(res);
}